﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsForms
{
    public partial class frmMyForm : Form
    {
        public frmMyForm()
        {
            InitializeComponent();
        }

        private void frmMyForm_Click(object sender, EventArgs e)
        {
            MessageBox.Show("您进行了单击窗体操作。");
        }

        private void frmMyForm_Load(object sender, EventArgs e)
        {
            this.Width = 800; //设置窗体宽度
            this.Height = 400; //设置窗体高度
            this.ForeColor = Color.Cyan;
            this.BackColor = Color.DarkGray;
            this.Text = "欢迎";
        }

        private void frmMyForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult cls = MessageBox.Show("是否确定关闭窗体?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
            if(cls==DialogResult.Yes)
            {
                e.Cancel = false;
            } else
            {
                e.Cancel = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form form = new Form();
            form.Show();
        }
    }
}
